<template>
    <div class="contentBox" :style="theme">
        <div class="userInfo">
            <span>{{ props.item.uname }}</span>
            <span>硬币:{{ props.item.money }}&emsp;B币:{{ 0 }}</span>
        </div>
        <div class="levelInfo" 
            :style="{ '--myLevelLenght':props.item.level_info?.current_exp / props.item.level_info?.next_exp * 100+'%' }"
            >
            <div v-if="props.item.level_info?.current_exp">
                <span>LV{{  props.item.level_info.current_level }}</span>
                <span></span>
                <span>LV{{ props.item.level_info.current_level+1 }}</span>
            </div>
            <div >当前成长{{props.item.level_info?.current_exp}}，距离升级Lv.{{props.item.level_info?.current_level+1}} 还需要{{props.item.level_info?.next_exp - props.item.level_info?.current_exp}}</div>
        </div>
        <div>
            <p><span>{{ props.item.other_info?.following }}</span><span>关注</span></p>
            <p><span>{{ props.item.other_info?.follower }}</span><span>粉丝</span></p>
            <p><span>{{ props.item.other_info?.dynamic_count }}</span><span>动态</span></p>
        </div>
        <div class="centerVipAd">
            <p>
                <span>大会员年卡不要钱</span>
                <span>返场特惠！免费送 仅限我这里xxxxxxxxxxxxxxxxxxxxxx</span>
            </p>
            <el-button color="white" style="color: #e84393;" >立即开通</el-button>
        </div>
        <ul class="selUl">
            <li><span><el-icon size="18" style="margin-right: 8px;"><UserFilled /></el-icon>个人中心</span> <el-icon><ArrowRightBold /></el-icon></li>
            <li><span><el-icon size="18" style="margin-right: 8px;"><Tools/></el-icon>投稿管理 </span> <el-icon><ArrowRightBold /></el-icon></li>
            <li><span><el-icon size="18" style="margin-right: 8px;"><StarFilled /></el-icon>推荐服务</span> <el-icon><ArrowRightBold /></el-icon></li>
        </ul>
        <div class="line"></div>
        <div class="goOut" @click="outLogin">
            <el-icon size="18" style="margin-right: 8px;"><Expand /></el-icon><span>退出登录</span>
        </div>
    </div>
</template>

<script lang="ts" setup>
import { Ref,ref } from "vue"
import { useStore } from 'vuex'
import { getThemes,resType } from '@/hooks/theme'
import { useRouter } from 'vue-router'


interface Props{
    item:{
        uname:string,
        face:string,
        level_info:{
            current_exp:number,     //当前成长值
            current_level:number,   //当前等级
            current_min:number,     
            next_exp:number         //下一等级需要的成长值
        },
        other_info:{
            dynamic_count:number,   //动态
            follower:number,        //粉丝
            following:number        //关注
        },
        money:number,               //硬币
    }
}

const props = defineProps<Props>()
const store = useStore()
const router = useRouter()
let theme: Ref<resType> = ref(getThemes(router.currentRoute.value.name as string))
    
//用户退出登录
function outLogin(){
let keys = document.cookie.match(/[^ =;]+(?=\=)/g);
if (keys) {
    keys.forEach(el=>{
        document.cookie = el+'=0;path=/;expires=' + new Date(0).toUTCString();
    })
    store.commit('outLogin');
    }
}


</script>

<style lang="scss" scoped>
$sysPopoverBackground: var(--backgroundColor);
$sysPopoverLableColor: var(--lableColor);
$sysPopoverTitleColor: var(--titleColor);
$sysPopoverHoverLableColor: var(--hoverLableColor);
.contentBox{
    padding: 30px 15px 15px 15px;
    @include flexColumnCenter;
    & div:nth-child(3){
        width: 100%;
        height: 80px;
        display: flex;
        justify-content: center;
        align-items: center;
    } 
    & div:nth-child(3) p{
        width: 33.3%;
        height: 60px;
        @include flexColumnCenter;
        border-radius: 8px;
        cursor: pointer;
        margin: 0;
    }
    & div:nth-child(3) p span:nth-child(1){
        font-weight: 600;
        color: $sysPopoverTitleColor;
        font-size: 20px;
    }
    & div:nth-child(3) p span:nth-child(2){
        color: $sysPopoverLableColor;
    }
    & div:nth-child(3) p:hover{
        background-color: $sysPopoverHoverLableColor;
    }
    & div:nth-child(3) p:hover span{
        color: #409EFF;
    }
}
.selUl{
    margin: 10px 0 0 0;
    padding: 0;
    width: 100%;
    list-style: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    & li{
        color: $sysPopoverLableColor;
        width: 100%;
        height: 38px;
        border-radius: 4px;
        display: flex;
        justify-content: space-between;
        align-items: center;
        transition: all .2s;
        box-sizing: border-box;
        padding: 0 15px;
    }
    & li:hover{
        background-color: $sysPopoverHoverLableColor;
    }
    & li span{
        display: flex;
        align-items: center;
    }
}
.userInfo{
    height: 60px;
    @include flexColumnCenter;
    & span:nth-child(1){
        font-weight: 600;
        font-size: 20px;
        color: $sysPopoverTitleColor;
    }
    & span:nth-child(2){
        font-size: 13px;
        color: $sysPopoverLableColor;
    }
}
.levelInfo{
    @include flexColumnCenter;
    width: 100%;
    height: 50px;
    & div {
        width: 100%;
        height: 25px;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
    & div:nth-child(1) span:nth-child(1) {
        height: 100%;
        color: white;
        -webkit-text-stroke: 2px #e17055;
    }
    & div:nth-child(1) span:nth-child(3) {
        height: 100%;
        color: white;
        -webkit-text-stroke: 2px #9499A0;
    }
    //进度条
    & div:nth-child(1) span:nth-child(2) {
        width: 80%;
        position: relative;
        height: 3px;
        border-radius: 2px;
        background-color: rgb(205, 208, 214,0.4);
    }
    & div:nth-child(1) span:nth-child(2)::after {
        content: "";
        position: absolute;
        width: var(--myLevelLenght);
        height: 3px;
        border-radius: 2px;
        background-color: #e17055;
    }
    & div:nth-child(2){
        color: $sysPopoverLableColor;
        font-size: 12px;
    }
}
.centerVipAd{
    width: 100%;
    height: 60px;
    background-image: url(../../assets/1bm7dE8GVM.png);
    background-size: 100%;
    border-radius: 8px;
    box-sizing: border-box;
    padding: 0 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    & p {
        width: 60%;
        height: 100%;
        @include flexColumnCenter;
    }
    & p span:nth-child(1){
        color: #e84393;
        font-size: 14px;
        font-weight: 600;
    }
    & p span:nth-child(2){
        width: 100%;
        font-size: 13px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    
}
.line{
    padding: 0;
    width: 100%;
    height: 1px;
    margin:10px 0;
    background: $sysPopoverHoverLableColor;
}
.goOut{
    color: $sysPopoverLableColor;
    width: 100%;
    height: 38px;
    display: flex;
    align-items: center;
    border-radius:4px;
    padding: 0 15px;
    box-sizing: border-box;
    cursor: pointer;
    &:hover{
        background-color: $sysPopoverHoverLableColor;
    }
}
</style>